var levelTraversal = function(root){
    let res =[],
        queue = [root]
    if(!root) return res
    while(queue.length){
        let length = queue.length
        let curr = []
        for(let i=0;i<length;i++){
            let node = queue.shift()
            curr.push(node.val)
            node.left && queue.push(node.left)
            node.right && queue.push(node.right)
        }       
        res.push(curr)
    }
}